package com.amigo.online.consumer.user.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.amigo.online.common.core.response.Meta;
import com.amigo.online.common.util.UploadTempUtil;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.amigo.online.common.base.controller.BaseConsumerController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.common.core.response.StatusCode;
import com.amigo.online.common.param.dto.user.AccountDto;
import com.amigo.online.common.param.dto.user.AroundPeopleDto;
import com.amigo.online.common.param.dto.user.AroundPeopleImgDto;
import com.amigo.online.common.param.dto.user.CompleteDto;
import com.amigo.online.common.param.dto.user.DeletePhotoDto;
import com.amigo.online.common.param.dto.user.GetReginIdDto;
import com.amigo.online.common.param.dto.user.PasswordDto;
import com.amigo.online.common.param.dto.user.PhotoDto;
import com.amigo.online.common.param.dto.user.ProbePeopleDto;
import com.amigo.online.common.param.dto.user.ReplacePhotoDto;
import com.amigo.online.common.param.dto.user.SexDto;
import com.amigo.online.common.param.dto.user.SuggestDto;
import com.amigo.online.common.param.dto.user.TipOffDto;
import com.amigo.online.common.param.dto.user.UserInfoDto;
import com.amigo.online.common.param.dto.user.UserNotifyDto;
import com.amigo.online.consumer.user.exception.FileUploadException;
import com.amigo.online.consumer.user.service.FileUploadService;
import com.amigo.online.consumer.user.service.UserService;
import com.amigo.online.consumer.user.service.VideoService;
import com.google.common.io.BaseEncoding;

/**
 * 用户相关
 * 
 * @author amigo
 *
 */
@RestController
@RequestMapping(value = "/user", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class UserController extends BaseConsumerController {

	@Autowired
	UserService userService;

	@Autowired
	VideoService videoService;

	@Autowired
	FileUploadService fileUploadService;

	/**
	 * 
	 * @Title: uploadVideoFile   
	 * @Description: (上传图片)
	 * @param: @param files
	 * @param: @return      
	 * @return: ResponseEntity<Response> 
	 * @author: zxy  QQ:1363320658
	 * @date:   2019年1月14日 下午2:18:00   
	 * @version V1.0      
	 * @throws
	 */
	@PostMapping("/upload/img")
	public ResponseEntity<Response> uploadVideoFile(@RequestPart(value = "files") MultipartFile[] files) {
		List<String> resultList = fileUploadService.handleMultiFileUploadList(files);
		return success(resultList);
	}

	/**
	 * 
	 * @Title: uploadImgFile   
	 * @Description: (上传视频)
	 * @param: @param files
	 * @param: @return      
	 * @return: ResponseEntity<Response> 
	 * @author: zxy  QQ:1363320658
	 * @date:   2019年1月14日 下午2:18:30   
	 * @version V1.0      
	 * @throws
	 */
	@PostMapping("/upload/video")
	public ResponseEntity<Response> uploadImgFile(@RequestPart(value = "files") MultipartFile[] files) {
		List<String> resultList = fileUploadService.handleMultiFileUploadList(files);
		return success(resultList);
	}
	
	/**
	 * 
	 * @Title: complete   
	 * @Description: (完善用户信息)
	 * @param: @param dto
	 * @param: @return      
	 * @return: ResponseEntity<Response> 
	 * @author: zxy  QQ:1363320658
	 * @date:   2019年1月14日 上午11:25:46   
	 * @version V1.0      
	 * @throws
	 */
	@PostMapping(value = "/complete/v1")
	public ResponseEntity<Response> complete(CompleteDto dto) {
		return userService.complete(dto);
	}

	/**
	 * 
	 * @Title: updateInfo   
	 * @Description: (更新用户信息)
	 * @param: @param dto
	 * @param: @return      
	 * @return: ResponseEntity<Response> 
	 * @author: zxy  QQ:1363320658
	 * @date:   2019年1月14日 上午11:25:32   
	 * @version V1.0      
	 * @throws
	 */
	@PostMapping(value = "/info/v1")
	public ResponseEntity<Response> updateInfo(UserInfoDto dto) {
		return userService.updateUserInfo(dto);
	}
	
	/**
	 * 
	 * @Title: newUserPhoto   
	 * @Description: (新增用户照片)
	 * @param: @param dto
	 * @param: @return      
	 * @return: ResponseEntity<Response> 
	 * @author: zxy  QQ:1363320658
	 * @date:   2019年1月14日 上午11:25:20   
	 * @version V1.0      
	 * @throws
	 */
	@PostMapping(value = "/photo/v1")
	public ResponseEntity<Response> newUserPhoto(PhotoDto dto) {
		if (dto.getFirstImg() == null || dto.getSort() == null) {
			throw new FileUploadException(StatusCode.BAD_REQUEST);
		}
		if (dto.getFirstImg() == 1 && dto.getSort() != 1) {
			throw new FileUploadException(StatusCode.BAD_REQUEST);
		}
		return userService.newUserPhoto(dto);
	}

	/**
	 * 
	 * @Title: repalceUserPhoto   
	 * @Description: (这里用一句话描述这个方法的作用)
	 * @param: @param dto
	 * @param: @return      
	 * @return: ResponseEntity<Response> 
	 * @author: zxy  QQ:1363320658
	 * @date:   2019年1月14日 上午11:25:12   
	 * @version V1.0      
	 * @throws
	 */
	@PostMapping(value = "/photo/repalce/v1")
	public ResponseEntity<Response> repalceUserPhoto(ReplacePhotoDto dto) {
		if (dto.getFirstImg() == null || dto.getSort() == null) {
			throw new FileUploadException(StatusCode.BAD_REQUEST);
		}
		return userService.repalceUserPhoto(dto);
	}

	/**
	 * 
	 * @Title: newTipOff   
	 * @Description: (举报用户)
	 * @param: @param dto
	 * @param: @return      
	 * @return: ResponseEntity<Response> 
	 * @author: zxy  QQ:1363320658
	 * @date:   2019年1月14日 上午11:25:00   
	 * @version V1.0      
	 * @throws
	 */
	@PostMapping(value = "/newTipOff/v1")
	public ResponseEntity<Response> newTipOff(TipOffDto dto) {
		return userService.newTipOff(dto);
	}
	
	/**
	 * 
	 * @Title: suggest   
	 * @Description: (用户建议)
	 * @param: @param dto
	 * @param: @return      
	 * @return: ResponseEntity<Response> 
	 * @author: zxy  QQ:1363320658
	 * @date:   2019年1月14日 上午11:24:48   
	 * @version V1.0      
	 * @throws
	 */
	@PostMapping(value = "/suggest/v1")
	public ResponseEntity<Response> suggest(SuggestDto dto) {
		return userService.suggest(dto);
	}

	// 完善用户信息
	@PostMapping(value = "/complete")
	public ResponseEntity<Response> complete(@RequestPart("file_avatar") MultipartFile[] fileAvatar, CompleteDto dto,
			@RequestHeader(value = "ACCESS_TOKEN", required = true) String token) throws IOException {
		if (fileAvatar != null && fileAvatar.length > 0) {
			String result = UploadTempUtil.uploadResourceImg(fileAvatar[0], token);
			Response parseObject = new Gson().fromJson(result, Response.class);
			if(((Meta)parseObject.getMeta()).getCode() == 401) {
				return failure(StatusCode.UNAUTHORIZED);
			}
			// TODO: 2019/10/11 重构时需要注意
			dto.setAvatar(getAddress(parseObject));
///			List<String> address = UploadImgUtil.uploadImg(fileAvatar);
//			if (address != null && address.size() >= 1) {
//				dto.setAvatar(address.get(0));
//			}
		}
		return userService.complete(dto);
	}

	// 更新用户信息
	@PostMapping(value = "/info")
	public ResponseEntity<Response> updateInfo(
			@RequestPart(value = "file_avatar", required = false) MultipartFile[] fileAvatar,
			@RequestHeader(value = "ACCESS_TOKEN") String token, UserInfoDto dto) throws IOException {
		if (fileAvatar != null && fileAvatar.length > 0) {
			String result = UploadTempUtil.uploadResourceImg(fileAvatar[0], token);
			Response parseObject = new Gson().fromJson(result, Response.class);
			if(((Meta)parseObject.getMeta()).getCode() == 401) {
				return failure(StatusCode.UNAUTHORIZED);
			}
			dto.setAvatar(getAddress(parseObject));

		}
		return userService.updateUserInfo(dto);
	}

	// 获得我的用户信息
	@GetMapping(value = "/info")
	public ResponseEntity<Response> getMyInfo() {
		return userService.getUserInfo();
	}

	// 根据id获得用户信息
	@GetMapping(value = "/info/{id}")
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public ResponseEntity<Response> getUserInfo(@PathVariable Long id) {
		ResponseEntity<Response> userInfoRs = userService.getUserInfoById(id);
		Map userInfoData = (Map) userInfoRs.getBody().getData();
		ResponseEntity<Response> countRs = videoService.getHomepageVideoCount(id);
		Map countData = (Map) countRs.getBody().getData();
		if (userInfoData != null) {
			userInfoData.putAll(countData);
		}
		return userInfoRs;
	}

	// 更改用户account号
	@PutMapping(value = "/account")
	public ResponseEntity<Response> updateUserAccount(HttpServletRequest request) {
		AccountDto dto = (AccountDto) getDto(request, AccountDto.class);
		return userService.updateUserAccount(dto);
	}

	// 新增用户照片
	@PostMapping(value = "/photo")
	public ResponseEntity<Response> newUserPhoto(
			@RequestPart(value = "file_photo", required = false) MultipartFile[] filePhoto,
			@RequestHeader(value = "ACCESS_TOKEN", required = true) String token, PhotoDto dto) throws IOException {
		logger.info(token);
		logger.info("上传开始");
		if (dto == null) {
			throw new FileUploadException(StatusCode.BAD_REQUEST);
		}
		if (dto.getFirstImg() == null || dto.getSort() == null) {
			throw new FileUploadException(StatusCode.BAD_REQUEST);
		}
		if (dto.getFirstImg() == 1) {
			if (dto.getSort() != 1) {
				throw new FileUploadException(StatusCode.BAD_REQUEST);
			}
		}

		if (filePhoto != null && filePhoto.length > 0) {
			String result = UploadTempUtil.uploadResourceImg(filePhoto[0], token);
			Response parseObject = new Gson().fromJson(result, Response.class);
			if(((Meta)parseObject.getMeta()).getCode() == 401) {
				return failure(StatusCode.UNAUTHORIZED);
			}
			dto.setPhoto(getAddress(parseObject));
///			List<String> address = UploadImgUtil.uploadImg(filePhoto);
//			if (address != null && address.size() >= 1) {
//				dto.setPhoto(address.get(0));
//			}
		}
		logger.info("上传结束");
		return userService.newUserPhoto(dto);
	}
	private String getAddress(Response parseObject) {
		String address = "";
		if (parseObject != null && parseObject.getData() != null) {
			Object data = parseObject.getData();
			if (data instanceof List) {
				List<String> addressList = (List<String>) data;
				address = addressList.get(0);
			}
		}
		return address;
	}

	@PostMapping(value = "/photo/repalce")
	public ResponseEntity<Response> repalceUserPhoto(
			@RequestPart(value = "file_photo", required = false) MultipartFile[] filePhoto,
			@RequestHeader(value = "ACCESS_TOKEN", required = true) String token, ReplacePhotoDto dto) throws IOException {
		if (dto == null) {
			throw new FileUploadException(StatusCode.BAD_REQUEST);
		}
		if (dto.getFirstImg() == null || dto.getSort() == null) {
			throw new FileUploadException(StatusCode.BAD_REQUEST);
		}
		if (filePhoto != null && filePhoto.length > 0) {
			String result = UploadTempUtil.uploadResourceImg(filePhoto[0], token);
			Response parseObject = new Gson().fromJson(result, Response.class);
			if(((Meta)parseObject.getMeta()).getCode() == 401) {
				return failure(StatusCode.UNAUTHORIZED);
			}
			dto.setNewPhoto(getAddress(parseObject));
		}
		return userService.repalceUserPhoto(dto);
	}

	// 根据id删除用户照片
	@PostMapping(value = "/photo/delete")
	public ResponseEntity<Response> deleteUserPhoto(HttpServletRequest request) {
		DeletePhotoDto dto = (DeletePhotoDto) getDto(request, DeletePhotoDto.class);
		return userService.deleteUserPhoto(dto);
	}

	// 获得用户照片列表
	@GetMapping(value = "/photos")
	public ResponseEntity<Response> getUserPhoto() {
		return userService.getUserPhotos();
	}

	// 根据用户id获得用户照片列表
	@GetMapping(value = "/photos/{id}")
	public ResponseEntity<Response> getUserPhotoByUid(@PathVariable Long id) {
		return userService.getUserPhotosByUid(id);
	}

	// 更改用户密码
	@PutMapping(value = "/password")
	public ResponseEntity<Response> updateUserPassword(HttpServletRequest request) {
		PasswordDto dto = (PasswordDto) getDto(request, PasswordDto.class);
		return userService.updateUserPassword(dto);
	}

	// 获得七牛云视频上传路径
	@GetMapping(value = "/qiniu/token/avatar")
	public ResponseEntity<Response> getUserQiniuToken() {
		return userService.getUserQiniuToken();
	}

	// 退出登陆
	@PostMapping(value = "/logout")
	public ResponseEntity<Response> logout() {
		return userService.logout();
	}

	// 获得七牛云照片上传路径
	@GetMapping(value = "/qiniu/token/photos")
	public ResponseEntity<Response> getQiniuPhotosToken() {
		return userService.getQiniuPhotosToken();
	}

	// 获得七牛云照片上传路径
	@GetMapping(value = "/qiniu/token/complain")
	public ResponseEntity<Response> getQiniucomplainToken() {
		return userService.getQiniucomplainToken();
	}

	// 获得七牛云视频上传路径
	@GetMapping(value = "/qiniu/token/video")
	public ResponseEntity<Response> getQiniuVideoToken() {
		return userService.getQiniuVideoToken();
	}

	// 获得mongoDB中制定id的信息
	@GetMapping(value = "/mongo/{id}")
	public ResponseEntity<Response> getUserInfoFromMongo(@PathVariable Long id) {
		return userService.getUserInfoFromMongo(id);
	}

	// 获得所有用户
	@GetMapping(value = "/getAll")
	public ResponseEntity<Response> getAll() {
		return userService.getAll();
	}

	// 获得用户附近的人
	@PostMapping(value = "/user/around")
	public ResponseEntity<Response> findAroundPeople(HttpServletRequest request) {
		AroundPeopleDto dto = (AroundPeopleDto) getDto(request, AroundPeopleDto.class);
		return userService.findAroundPeople(dto);
	}

	// 获得附近的头像
	@PostMapping(value = "/user/partAround")
	public ResponseEntity<Response> findPartAroundPeoleImg(HttpServletRequest request) {
		AroundPeopleImgDto dto = (AroundPeopleImgDto) getDto(request, AroundPeopleImgDto.class);
		return userService.findPartAroundPeoleImg(dto);
	}

	// 获得附近的头像
	@PostMapping(value = "/v1/user/partAround")
	public ResponseEntity<Response> tstfindPartAroundPeoleImg(HttpServletRequest request) {
		AroundPeopleImgDto dto = (AroundPeopleImgDto) getDto(request, AroundPeopleImgDto.class);
		return userService.testFindPartAroundPeoleImg(dto);
	}

	// 获得附近的头像
	@PostMapping(value = "/v2/user/partAround")
	public ResponseEntity<Response> testfindPartAroundPeoleImgV2(HttpServletRequest request) {
		AroundPeopleImgDto dto = (AroundPeopleImgDto) getDto(request, AroundPeopleImgDto.class);
		return userService.testFindPartAroundPeoleImgV2(dto);
	}

	// 获得附近的头像
	@PostMapping(value = "/tantan/partAround")
	public ResponseEntity<Response> findTantanPartAroundPeoleImg(HttpServletRequest request) {
		AroundPeopleImgDto dto = (AroundPeopleImgDto) getDto(request, AroundPeopleImgDto.class);
		return userService.findTantanPartAroundPeoleImg(dto);
	}

	@PostMapping(value = "/v3/user/partAround")
	public ResponseEntity<Response> findPartAroundPeoleImgV3(HttpServletRequest request) {
		AroundPeopleImgDto dto = (AroundPeopleImgDto) getDto(request, AroundPeopleImgDto.class);
		return userService.findPartAroundPeoleImgV3(dto);
	}

	// 获得附近的头像
	@PostMapping(value = "/v3/tantan/partAround")
	public ResponseEntity<Response> findTantanPartAroundPeoleImgV3(HttpServletRequest request) {
		AroundPeopleImgDto dto = (AroundPeopleImgDto) getDto(request, AroundPeopleImgDto.class);
		return userService.findTantanPartAroundPeoleImgV3(dto);
	}

	// 获得用户好友数 关注数 粉丝数 群数
	@GetMapping(value = "/userInfoNum/{id}")
	public ResponseEntity<Response> getUserInfoNum(@PathVariable Long id) {
		return userService.getUserInfoNum(id);
	}

	// 举报用户
	@PostMapping(value = "/newTipOff")
	public ResponseEntity<Response> newTipOff(@RequestParam(value = "image", required = false) MultipartFile[] image,
			@RequestHeader(value = "ACCESS_TOKEN") String token, TipOffDto dto) throws IOException {
		logger.info(token);
		logger.info("上传开始");
		List<String> address = new ArrayList<>();
		if (image != null) {
			for (MultipartFile multipartFile : image) {
				String result = UploadTempUtil.uploadResourceImg(multipartFile, token);
				Response parseObject = new Gson().fromJson(result, Response.class);
				if(((Meta)parseObject.getMeta()).getCode() == 401) {
					return failure(StatusCode.UNAUTHORIZED);
				}
				address.add(getAddress(parseObject));
			}

//			address = UploadImgUtil.uploadImg(image);
			if (address.size() == 1) {
				dto.setImg1(address.get(0));
			}
			if (address.size() == 2) {
				dto.setImg1(address.get(0));
				dto.setImg2(address.get(1));
			}
			if (address.size() == 3) {
				dto.setImg1(address.get(0));
				dto.setImg2(address.get(1));
				dto.setImg3(address.get(2));
			}
		}
		// dto.setImg1("111");
		// dto.setImg2("222");
		// dto.setImg3("333");
		logger.info("上传结束");
		return userService.newTipOff(dto);
	}

	// 获得地区id
	@PostMapping(value = "/getRegionId")
	public ResponseEntity<Response> getRegionId(HttpServletRequest request) {
		GetReginIdDto dto = (GetReginIdDto) getDto(request, GetReginIdDto.class);
		return userService.getRegionId(dto);
	}

	// 校验用户token
	@GetMapping(value = "/userInfo/{token}")
	public ResponseEntity<Response> checktoken(@PathVariable String token) {
		return userService.checktoken(token);
	}

	@PutMapping(value = "/sex")
	public ResponseEntity<Response> updateUserSex(HttpServletRequest request) {
		SexDto dto = (SexDto) getDto(request, SexDto.class);
		return userService.updateUserSex(dto);
	}

	/*----------------*/

	@GetMapping(value = "/bindface/{facebookID}")
	public ResponseEntity<Response> bindface(@PathVariable String facebookID) {
		return userService.bindface(facebookID);
	}

	@GetMapping(value = "/bind/{type}/{flag}/{code}")
	public ResponseEntity<Response> bind(@PathVariable Integer type, @PathVariable String flag,
			@PathVariable String code) {
		return userService.bind(type, flag, code);
	}

	@PostMapping(value = "/privacy")
	public ResponseEntity<Response> setSecretLevel(HttpServletRequest request) {
		UserInfoDto dto = (UserInfoDto) getDto(request, UserInfoDto.class);
		return userService.setSecretLevel(dto);
	}

	@PostMapping(value = "/notify")
	public ResponseEntity<Response> setNotifyLevel(HttpServletRequest request) {
		UserNotifyDto dto = (UserNotifyDto) getDto(request, UserNotifyDto.class);
		return userService.setNotifyLevel(dto);
	}

	@GetMapping(value = "/unbind/{type}")
	public ResponseEntity<Response> unBind(@PathVariable Integer type) {
		return userService.unBind(type);
	}

	@GetMapping(value = "/area/{lang}/{id}")
	public ResponseEntity<Response> getAreaInfo(@PathVariable String lang, @PathVariable Long id) {
		return userService.getAreaInfo(lang, id);
	}

	/**
	 * 更新用户lastLoginTime
	 * 
	 */
	@PostMapping(value = "/updateLoginTime")
	public ResponseEntity<Response> updateLastLoginTime() {
		return userService.updateLastLoginTime();
	}

	/**
	 * 探探快速匹配
	 * 
	 * @param
	 * @return
	 */
	@PostMapping(value = "/probe")
	public ResponseEntity<Response> probePeople(@RequestBody ProbePeopleDto probePeopleDto,
			@RequestHeader("lng") String lng, @RequestHeader("lat") String lat) {
		logger.info("经度:" + lng + "纬度:" + "lat");
		if (probePeopleDto.getLat() == null) {
			probePeopleDto.setLat(lat);
		}
		if (probePeopleDto.getLng() == null) {
			probePeopleDto.setLng(lng);
		}
		return userService.probePeople(probePeopleDto);
	}

	/**
	 * 用户建议 2018/10/09 kml
	 */
	@PostMapping(value = "/suggest")
	public ResponseEntity<Response> suggest(@RequestParam(value = "images") MultipartFile[] images,
											@RequestHeader(value = "ACCESS_TOKEN") String token,
											SuggestDto dto) throws IOException {
		List<String> address = new ArrayList<>();
		if (images != null) {
			for (MultipartFile image : images) {
				String result = UploadTempUtil.uploadResourceImg(image, token);
				Response parseObject = new Gson().fromJson(result, Response.class);
				if(((Meta)parseObject.getMeta()).getCode() == 401) {
					return failure(StatusCode.UNAUTHORIZED);
				}
				address.add(getAddress(parseObject));
			}
			for (int i = 0; i < address.size(); i++) {
			}
			if (address.size() == 1) {
				dto.setImg1(address.get(0));
			}
			if (address.size() == 2) {
				dto.setImg1(address.get(0));
				dto.setImg2(address.get(1));
			}
			if (address.size() == 3) {
				dto.setImg1(address.get(0));
				dto.setImg2(address.get(1));
				dto.setImg3(address.get(2));
			}
			if (address.size() == 4) {
				dto.setImg1(address.get(0));
				dto.setImg2(address.get(1));
				dto.setImg3(address.get(2));
				dto.setImg4(address.get(3));
			}
			if (address.size() == 5) {
				dto.setImg1(address.get(0));
				dto.setImg2(address.get(1));
				dto.setImg3(address.get(2));
				dto.setImg4(address.get(3));
				dto.setImg5(address.get(4));
			}
		}
		return userService.suggest(dto);
	}

	@PostMapping(value = "/avatar/s/{userId}")
	public void rebackImgStream(@PathVariable("userId") Long userId, HttpServletResponse response) {
		String result = userService.rebackImgStream(userId);
		try {
			response.setHeader("Content-Type", "image/jpg;charset=UTF-8");
			ServletOutputStream outputStream = response.getOutputStream();
			outputStream.write(BaseEncoding.base64().decode(result));
			outputStream.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * 根据nickname或者手机号或者accout查询用户
	 * 
	 * @param
	 * 
	 * @return: 用户id,nickname,avatar
	 */
	@GetMapping(value = "/getUserByNicknameOrPhone/{param}")
	public ResponseEntity<Response> getUserByNicknameOrPhone(@PathVariable String param) {
		return userService.getUserByNicknameOrPhone(param);
	}

	/**
	 * 
	 * @Title: getInviteCode @Description: 获取邀请码 @param @return
	 * ResponseEntity<Response> @throws
	 */
	@GetMapping(value = "/inviteCode")
	public ResponseEntity<Response> getInviteCode() {
		return userService.getInviteCode();
	}

	/**
	 * 
	 * @Title: useInviteCode @Description: 使用邀请码 @param @return
	 * ResponseEntity<Response> @throws
	 */
	@GetMapping(value = "/useInviteCode/{code}")
	public ResponseEntity<Response> useInviteCode(@PathVariable String code) {
		return userService.useInviteCode(code);
	}

	/**
	 * 
	 * @Title: inviteCodeView @Description: 获取自己的邀请码使用情况(分享有礼) @param @return
	 * ResponseEntity<Response> @throws
	 */
	@GetMapping(value = "/inviteCodeView")
	public ResponseEntity<Response> inviteCodeView() {
		return userService.inviteCodeView();
	}
}
